Passed
Push — develop ( 56e412...b602c4 )
by Bjarn
01:15
created

SitesController.executeLink   A

Complexity

Conditions 1

Size

Total Lines 10
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 10
c 0
b 0
f 0
rs 9.9
cc 1
1
import {writeFileSync} from 'fs'
2
import Nginx from '../services/nginx'
3
import nginxSiteConfig from '../templates/nginxSite'
4
import {ensureDirectoryExists} from '../utils/filesystem'
5
import {getConfig, jaleSitesPath} from '../utils/jale'
6
7
class SitesController {
8
9
    executeLink = async (): Promise<void> => {
10
        const config = await getConfig()
11
        const domain = process.cwd().substring(process.cwd().lastIndexOf('/') + 1)
12
        const hostname = `${domain}.${config.domain}`
13
14
        await ensureDirectoryExists(jaleSitesPath)
15
16
        await writeFileSync(`${jaleSitesPath}/${hostname}.conf`, nginxSiteConfig(hostname, process.cwd()))
17
18
        await (new Nginx()).reload
19
    }
20
21
}
22
23
export default SitesController